# coding=utf-8
# 全世界最帅的帅哥
from flask_restful import Resource
from ysgg1_club_auth.auth_views.user_views import update_user, delete_user, enable_or_disable_user, get_user_info
from ysgg1_club_auth.auth_views.login_views import login
from ysgg1_club_auth.auth_views.register_views import register_controller


class RegisterResource(Resource):

    def post(self):
        return register_controller()


class LoginResource(Resource):
    def post(self):
        return login()


class UserResource(Resource):

    def get(self, user_id=None):
        pass

    def post(self, action=None):
        if action == "disable" or action == "enable":
            return enable_or_disable_user()
        elif action == "get_user_info":
            return get_user_info()
        else:
            return {"code": 404, "message": "出错了"}

    def put(self, user_id=None):
        if user_id:
            return update_user(user_id=user_id)
        return {"code": 500, "success": False, "message": "更新失败"}

    def delete(self, user_id=None):
        if not user_id:
            return {"code": 500, "success": False, "message": "删除失败"}
        return delete_user(user_id)
